<template>
  <!-- 模板内容：只能有一个div  -->
  <div>
    <!-- 主页面内容 -->
    <div class="contentmenu">
      <ul>
        <li>
          <div class="smallbox" >
            <h2>读就送</h2>
            <h3>加入书架阅读5分钟后即可免费获得本书</h3>
            <img :src="list" alt="" />
            <input type="button" value="立即阅读"  @click="fn"/>
            <h4 @click="ff">换一本</h4>
          </div>
        </li>
        <li>
          <div class="smallbox" >
            <h2>读就送</h2>
            <h3>加入书架阅读5分钟后即可免费获得本书</h3>
            <img :src="list1" alt="" />
            <input type="button" value="立即阅读"  @click="fn"/>
            <h4 @click="ff1">换一本</h4>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import Vue from 'vue';
import { Toast } from 'vant';
Vue.use(Toast);
export default {
  name: "app",
  data() {
    return {
        // arr:{},
      list: {},
      list1:{},
      count: 0,
      count1:1
    };
  },
  methods: {
     fn(){
        //  Vant轻提示 用户交互 
         Toast('暂无书源，等待更新');
     },
    async ff() {
      let { data } = await axios.get("./wechatBook.json");
      this.list = data.librarian[this.count].imgSrc;
    //   console.log(this.count.length)
      if(this.count === 5){
          this.count =1
      }
      return this.count++;
    },
    async ff1() {
      let { data } = await axios.get("./wechatBook.json");
      this.list1 = data.librarian[this.count1+1].imgSrc;
      if(this.count1 === 4){
          this.count1 =1
      }
      return this.count1++;
    },
    // async fn_getDate() {
    //   let { data } = await axios.get("./wechatBook.json");
    //   this.arr=data.txt
    // },
  },
  created() {
    this.ff();
    this.ff1();
    // this.fn_getDate()
  },
};
</script>

<style scoped>
/* css样式 */
.contentmenu {
  background: #eee;
}
.smallbox {
  width: 90%;
  margin: 5%;
  height: 8rem;
  background: #fff;
  border: 1px solid #fff;
  border-radius: 0.2rem;
  text-align: center;
}
h2 {
  font-size: 0.5rem;
  text-align: center;
  font-weight: normal;
}
h3 {
  font-size: 0.2rem;
  text-align: center;
  font-weight: normal;
}
input {
  width: 5rem;
  height: 0.7rem;
  font-size: 0.3rem;
  border: 1px solid rgb(95, 95, 230);
  background: rgb(95, 95, 230);
  color: #fff;
  font-size: 0.32rem;
  border-radius: .2rem;
}
h4 {
  font-size: 0.3rem;
  text-align: center;
}
img {
  width: 3.5rem !important;
  height: 3.2rem !important;
}
h4 {
  color: lightseagreen;
}
</style>